package com.karolak.stock.oscilator;

import com.karolak.stock.data.DataManager;
import com.karolak.stock.indicator.Indicator;

public class BandOsc extends Oscilator {

	private Indicator bandTrOsc;
	private Indicator bandSwOsc;

	private double offLevel  = 0.0001; //0;
	private double swOnLevel = 0.0001;//0.0001;
	private double trOnLevel = 0.0001;//0.0001;

	public BandOsc(String name, DataManager dataManager, Indicator switcher, BandTrOsc bandTrOsc, BandSwOsc bandSwOsc) {
		super(dataManager, 0, switcher);
		this.bandTrOsc = bandTrOsc;
		this.bandSwOsc = bandSwOsc;
		setName(name);
	}

	@Override
	public double execute(double x) {
		double switcher = getDataManager().getLast(getInput().getName());
		double sw = getDataManager().getLast(getBandSwOsc().getName());
		double tr = getDataManager().getLast(getBandTrOsc().getName());

//		if (switcher < getOffLevel()) {
//			return 0;
//		}

//		if (switcher < getSwOnLevel()) {
//			return sw;
//		}
//		if (switcher > getTrOnLevel()) {
//			return tr;
//		}
		
		if (switcher == 0.5) {
			return sw;
		}
		if (switcher == 1) {
			return tr;
		}
		return 0;
	}

	protected Indicator getBandTrOsc() {
		return bandTrOsc;
	}

	protected Indicator getBandSwOsc() {
		return bandSwOsc;
	}

	protected double getSwOnLevel() {
		return swOnLevel;
	}

	protected void setSwOnLevel(double swOnLevel) {
		this.swOnLevel = swOnLevel;
	}

	protected double getTrOnLevel() {
		return trOnLevel;
	}

	protected void setTrOnLevel(double trOnLevel) {
		this.trOnLevel = trOnLevel;
	}

	protected double getOffLevel() {
		return offLevel;
	}

	protected void setOffLevel(double offLevel) {
		this.offLevel = offLevel;
	}
}
